// Copyright (c) 2007 Alistair Jones
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.codegen;

import org.junit.runner.JUnitCore;

import java.io.File;
import java.io.FilenameFilter;
import java.util.List;
import java.util.ArrayList;

public class TestRunner {
    public static void main(String[] args) throws ClassNotFoundException {
        String resourcePath = TestRunner.class.getPackage().getName().replace('.', '/');

        String directory = TestRunner.class.getResource("/" + resourcePath).getFile();

        String[] classFiles = new File(directory).list(new FilenameFilter() {
            public boolean accept(File directory, String name) {
                return name.endsWith("Test.class");
            }
        });

        List<String> classes = new ArrayList<String>();
        for (String classFile : classFiles) {
            classes.add(TestRunner.class.getPackage().getName() + "." + classFile.replaceAll(".class", ""));
        }

        JUnitCore.main(classes.toArray(new String[classes.size()]));
    }
}
